//
//  UIWindow+FunHierarchy.m
//  XinLing
//
//  Created by 于鹏 on 2017/9/15.
//  Copyright © 2017年 YIVIEW. All rights reserved.
//

#import "UIWindow+FunHierarchy.h"

@implementation UIWindow (FunHierarchy)

- (UIViewController *)fun_currentViewController {
    UIViewController *result = [self rootViewController];
    while (result.presentedViewController) {
        result = result.presentedViewController;
    }
    if ([result isKindOfClass:[UITabBarController class]]) {
        result = [(UITabBarController *)result selectedViewController];
    }
    if ([result isKindOfClass:[UINavigationController class]]) {
        result = [(UINavigationController *)result topViewController];
    }
    return result;
}

@end
